package com.bjsxt;

import java.io.*;

public class FileCopyTools {
    public static void main(String[] args) {
            copyFile("d:/itbz.jpg","d:/abc.jpg");
    }
    /**
     * 文件拷贝方法
     */
    public static void copyFile(String src,String des){
        FileInputStream fis = null;
        BufferedInputStream bis = null;
        FileOutputStream fos = null;
        BufferedOutputStream bos = null;

        try{
            bis = new BufferedInputStream(new FileInputStream(src));
            bos = new BufferedOutputStream(new FileOutputStream(des));
            int temp = 0;
            while((temp = bis.read()) != -1){
                bos.write(temp);
            }
            bos.flush();
        }catch(Exception e){
            e.printStackTrace();
        }finally{
            try{
                if(bis != null){
                    bis.close();
                }
                if(fis != null){
                    fis.close();
                }
                if(bos != null){
                    bos.close();
                }
                if(fos != null){
                    fos.close();
                }
            }catch(Exception e){
                e.printStackTrace();
            }
        }
    }
}
